#import "SongsCustomCell.h"

@interface SongsCustomCell ()


@property UIImage* favouritesImage;
@property SongsSingleton* singleton;
@end


@implementation SongsCustomCell

- (IBAction)addOrRemoveFavourites:(id)sender {
    //Proverka dali veche sushtestvuva vuv favourites
    //Ako su6testvuva premahvame
    //Ako ne su6testvuva dobavqme (ocvetqvame kartinkata)
    self.favouritesImage = [[UIImage alloc] init];
    
    if ([self.singleton isFavoriteSongWithIndex:[sender tag]]) {
        self.favouritesImage = [UIImage imageNamed:@"favourites_not_added.png"];
        [self.singleton removeFromFavoritesSongWithIndex:[sender tag]];
        self.addedToFavourites = NO;
    }
    else{
         self.favouritesImage = [UIImage imageNamed:@"favourites_added.png"];
        [self.singleton addToFavoritesSongWithIndex:[sender tag]];
        self.addedToFavourites = YES;
    }
    
    [self.favouritesButton setImage:self.favouritesImage forState:UIControlStateNormal];
[[NSNotificationCenter defaultCenter] postNotificationName:@"reload" object:nil];
}

- (void)awakeFromNib {

    [super awakeFromNib];
    self.addedToFavourites = NO;
    
    
    [self setOpaque:NO];
    [self setBackgroundColor:[UIColor clearColor]];
    
 
    self.singleton =[[SongsSingleton alloc]init];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
